/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.yunhoo.base.db.impl;

import com.ibatis.dao.client.DaoManager;
import com.ibatis.dao.client.template.SqlMapDaoTemplate;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.yunhoo.base.model.Department;
import com.yunhoo.sys.db.util.DbTool;
import com.yunhoo.base.db.dao.DepartmentDao;
import java.sql.SQLException;
import java.util.List;

/**
 *
 * @author Administrator
 */
public class DepartmentDaoImpl extends SqlMapDaoTemplate implements DepartmentDao {

    private static SqlMapClient sqlmap;
    private String nameSpace = "department.";

    public DepartmentDaoImpl(DaoManager daoManager) {
        super(daoManager);
        sqlmap = DbTool.getSqlMapClient();
    }

    @Override
    public void insert(Department dept) throws SQLException {
        System.out.println(nameSpace + "insert");
        sqlmap.insert(nameSpace + "insert", dept);
    }

    @Override
    public void update(Department dept) throws SQLException {
        System.out.println(nameSpace + "update");
        sqlmap.update(nameSpace + "update", dept);
    }

    @Override
    public void delete(Department dept) throws SQLException {
        System.out.println(nameSpace + "delete");
        sqlmap.delete(nameSpace + "delete", dept);
    }

    @Override
    public void deleteById(Department dept) throws SQLException {
        System.out.println(nameSpace + "deleteById");
        sqlmap.delete(nameSpace + "deleteById", dept);
    }

    @Override
    public Department queryById(Department dept) throws SQLException {
        System.out.println(nameSpace + "queryById");
        return (Department) sqlmap.queryForObject(nameSpace + "queryById", dept);
    }

    @Override
    public List<Department> queryAll(Department dept) throws SQLException {
        return sqlmap.queryForList(nameSpace + "queryAll", dept);
    }

    @Override
    public void updateIsEnd(Department dept) throws SQLException {
        System.out.println(nameSpace + "updateIsEnd");
        sqlmap.update(nameSpace + "updateIsEnd", dept);
    }

    @Override
    public Department nameRepeatForInsert(Department dept) throws SQLException {
        System.out.println(nameSpace + "nameRepeatForInsert");
        return (Department) sqlmap.queryForObject(nameSpace + "nameRepeatForInsert", dept);
    }

    @Override
    public Department nameRepeatForUpdate(Department dept) throws SQLException {
        System.out.println(nameSpace + "nameRepeatForUpdate");
        return (Department) sqlmap.queryForObject(nameSpace + "nameRepeatForUpdate", dept);
    }

    @Override
    public List<Department> directSubNodes(Department dept) throws SQLException {
        System.out.println(nameSpace + "directSubNodes");
        return sqlmap.queryForList(nameSpace + "directSubNodes", dept);
    }

    @Override
    public List<Department> queryListByOrgAndYear(Department dept) throws SQLException {
        System.out.println(nameSpace + "queryListByOrgAndYear");
        return sqlmap.queryForList(nameSpace + "queryListByOrgAndYear", dept);
    }
}
